package com.ss.android.article.base.feature.category.activity;

import android.support.v4.app.Fragment;

import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.a.ArticleConstants;
import com.ss.android.article.base.feature.pgc.PgcSearchActivity;
import com.ss.android.article.base.feature.subscribe.activity.j;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class CategorySearchActivity extends PgcSearchActivity {
    public CategorySearchActivity() {

    }

    public final Fragment a() {
        return new j() {

            public final String a() {
                char v1_2;
                StringBuilder v3;
                StringBuilder v2;
                String v0 = null;
                if (!android.support.design.a.isTextEmpty(this.l)) {
                    try {
                        v2 = new StringBuilder(
                                String.format(ArticleConstants.apiWapSearchUrl,
                                        "search_channel",
                                        URLEncoder.encode(this.l, "UTF-8")));
                        AppUtil.a(v2);
                        String v1_1 = v2.indexOf("#") > 0 ? "&" : "#";
                        v2.append(v1_1);
                        v3 = v2.append("tt_daymode=");
                        AppData.getInstance();
                        if (AppData.isNightMode()) {
                            v1_2 = '0';
                        } else {
                            v1_2 = '1';
                        }
                        v3.append(v1_2);
                        v0 = v2.toString();
                    } catch (UnsupportedEncodingException unsupportedEncodingException) {
                        unsupportedEncodingException.printStackTrace();
                    }
                }

                return v0;
            }
        };
    }

    public void init() {
        JSONObject v8;
        long v4 = 0;
        super.init();
        JSONObject v0 = null;
        if(!android.support.design.a.isTextEmpty(this.gdExtJson)) {
            try {
                v8 = new JSONObject(this.gdExtJson);
            }
            catch(Exception v1) {
                v8 = v0;
            }

            MobClickCombiner.onEvent(this, "all_category", "enter", v4, v4, v8);
        }
    }
}

